import { _decorator, Animation, Component, Node } from 'cc';
import { aa } from '../frame/FrameCore';
const { ccclass, property } = _decorator;

@ccclass('SpineCtrl')
export class SpineCtrl extends Component {
    // @property(sp.Skeleton) spine:sp.Skeleton = null;
    @property spineAnm = "animation"
    @property(Animation) anm:Animation = null;
    @property playOnLoad = true;
    @property time = 1;

    onEnable(){
        if(this.playOnLoad){
            this.play();
        }

    }
    onDisable(): void {
        this.stop();
    }
    playAnm(anm:string){
        this.spineAnm = anm;
        this.play();
    }

    stop() {
        // if(this.spine!==null) this.spine.clearAnimations();
        if(this.anm!==null) {
            this.anm.stop();
        }
    }

    play() {
        // if(this.spine!==null) this.spine.animation = this.spineAnm;
        if(this.anm!==null){
            this.anm.play();
        }
        if(this.time>0){
            this.scheduleOnce(()=>{
                aa.res.put(this.node);
            },this.time)
        }
       
    }



    clear() {

       

    }
}

